﻿using RPAVIEW.util;
using RPAVIEW.views.controlLibrary;
using RPAVIEW.views.OtherPages;
using SUNRPA.CONTROLS.IMPL.domain.flowItemParam;
using System.Windows;
using System.Windows.Controls;

namespace RPAVIEW.views.EditPage.flows.SetWebDDLN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        public Input() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            this.webObj.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.eleImg.GetBindingExpression(Image.SourceProperty).UpdateSource();
            this.selectType.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.matchMethod.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.selectValue.GetBindingExpression(SelVarTextBox.text).UpdateSource();
        }

        /// <summary>
        /// 由于目前并没有元素库功能，所以现在所有元素操作都必须直接选择。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GetElement(object sender, System.Windows.RoutedEventArgs e) {
            MainWindow main = WindowUtil.GetWindow<MainWindow>();
            WindowUtil.MinSizeWindow(main);
            GetEleWindow eleWindow = new GetEleWindow((ele)=>{
                SetWebDDLNParam param = ParamUtil.GetCurrentParam<SetWebDDLNParam>();
                param.WebEle = ele;
            });
            eleWindow.Show();
            eleWindow.RegistHotKey();
        }

        private void SelectTypeChanged(object sender, SelectionChangedEventArgs e) {
            int st = this.selectType.SelectedIndex;
            if(st == 0) { 
                this.matchMethodRow.Height = GridLength.Auto;
            } else { 
                this.matchMethodRow.Height = new GridLength(0);
            }
        }
    }
}
